#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int triangleNumber1(vector<int>& nums)
{
    int x, y, z = 0;
    int count = 0;
    sort(nums.begin(), nums.end());
    for (int x = 0; x < nums.size(); x++)
    {
        for (int y = x + 1; y < nums.size(); y++)
        {
            for (int z = y + 1; z < nums.size(); z++)
            {
                if (nums[x] + nums[y] > nums[z])
                {
                    count++;
                }
            }
        }
    }
    return count;
}

int triangleNumber2(vector<int>& nums)
{
    int count = 0;
    sort(nums.begin(), nums.end());
    for (int i = nums.size() - 1; i >= 2; i--)
    {
        int right = i - 1;
        int left = 0;
        while (left < right)
        {
            if (nums[left] + nums[right] > nums[i])
            {
                count += right - left;
                --right;
            }
            else
            {
                left++;
            }

        }
    }
    return count;
}


int main()
{
    return 0;
}